package com.jzo2o.market.controller.operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.market.model.dto.request.ActivityQueryForPageReqDTO;
import com.jzo2o.market.model.dto.request.ActivitySaveReqDTO;
import com.jzo2o.market.model.dto.response.ActivityInfoResDTO;
import com.jzo2o.market.service.IActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController("operationActivityController")
@RequestMapping("/operation/activity")
@Api(tags = "运营端-活动相关接口")
public class ActivityController {

    @Resource
    private IActivityService activityService;

    @PostMapping ("/revoke/{id}")
    @ApiOperation("撤销活动")
    @ApiImplicitParam(name = "id",value = "活动id",required = true,dataTypeClass = Long.class)
    public void revokeActivity(@PathVariable Long id) {
        activityService.revokeByActivityId(id);
    }
    @PostMapping("/save")
    @ApiOperation("新增优惠券")
    public void add(@RequestBody ActivitySaveReqDTO dto) {
        activityService.add(dto);
    }

    @GetMapping("/page")
    @ApiOperation("分页查询优惠券")
    public PageResult<ActivityInfoResDTO> page(ActivityQueryForPageReqDTO dto) {
        return activityService.selectByPage(dto);
    }
//
//    @GetMapping("/{id}")
//    @ApiOperation("根据活动id查询回显")
//    public ActivityInfoResDTO selectById(@PathVariable("id") Long id) {
//        return activityService.selectById(id);
//    }

    @GetMapping("/{id}")
    @ApiOperation("根据活动id查询回显")
    public ActivityInfoResDTO selectById(@PathVariable("id") Long id) {
        return activityService.queryById(id);
    }
}
